<?php
$id				= gpc_getIntPost("id",$id);
$name			= gpc_getStringPost("Name");
$urlstring		= gpc_getStringPost("URL",$name);
$title			= gpc_getStringPost("Title",$name);
$sologan		= gpc_getStringPost("Sologan");
$Tag 			= gpc_getStringPost("Tag");
$category 		= gpc_getIntPost("Category");
$TopBottomOrder	= gpc_getIntPost("TopBottomOrder",-1);
$order			= gpc_getIntPost("Order",-1);
$status			= gpc_getIntPost("Status");
$descriptions 	= gpc_getStringPost("Description");
$content		= gpc_getStringPost("Content");

$metatitle		= gpc_getStringPost("MetaTitle",$title);
$metakeywords	= gpc_getStringPost("MetaKeywords");
$metadescription= gpc_getStringPost("MetaDescription");
$isHighLine		= gpc_getBoolPost("HighLine",0);


$ImgIntro 		= gpc_getStringPost('ImgIntro');
$ImgBanner 		= gpc_getStringPost('ImgBanner');

// check--------------------
$urlstring=Trim_Url($urlstring);

if($category==0)
{
	error_transfer("Please select Category");
}else if(empty($name))
{
	error_transfer("Please enter Name");
}

$descriptions	= replace_pathlocal($descriptions);
$content		= replace_pathlocal($content);

//check urlcontent
CheckUrlString($urlstring,"tblblog",$category);
//get order category same parent;
$order          = GetOrderForInsert($TopBottomOrder,$order,$category,"tblblog");


if($act=="insertcontent")
{
    $sql_insert = "INSERT INTO tblblog
    	(iParentId,cName,cImage,cBanner,
    	cDescription,cContent,dPostDate,cPoster,
    	iStatus,iOrder,iCountView,cUrlString,cMetaTitle,cMetaDescription,cMetaKeywords,cLanguage)
    VALUES
    	($category,'$name','$ImgIntro', '$ImgBanner',
    	'$descriptions','$content','$postdate','$poster',
    	'$status',$order,0,'$urlstring','$metatitle','$metadescription','$metakeywords','$language')";

    $dbsql->query($sql_insert);

	Insert_Tracking("add Content : $name");
	page_transfer("Add Content Success !","id=$category");
}
elseif($id>0)
{
	$sql_update = "UPDATE tblblog SET
				iParentId	 	= $category,
				cName 			= '$name',
				cImage 			= '$ImgIntro',
				cBanner 		= '$ImgBanner',
				cDescription	= '$descriptions',
				cContent 		= '$content',
                ".(($order>0)? 'iOrder='.$order.',': '')."
				iStatus 		= '$status',
				cUrlString 		= '$urlstring',
				cMetaTitle 		= '$metatitle',
				cMetaDescription= '$metadescription',
				cMetaKeywords 	= '$metakeywords'
				WHERE iId= $id";

	$dbsql->query($sql_update);

	Insert_Tracking(" Edit Content : $name");
	page_transfer("Update Content Success !",getUrlBack());
}
exit();
?>
